home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Goodies / AutoGuest / PPCAutoGuest.a < prev    next >
Text File  |  1992-12-03  |  3KB  |  137 lines

  1. ;;
  2. ;;  PPC Patch by Paul Young, 8/26/91
  3. ;;
  4. ;;    Some modifications by Greg Anderson, 9/5/91 & 9/17/91
  5. ;;
  6.  
  7.     CASE        ON
  8.  
  9.     INCLUDE        'Traps.a'
  10.     INCLUDE        'PPCToolbox.a'
  11.  
  12.  
  13. ;;
  14. ;; This record is from PPCToolbox.a.  I'm not sure why I'm
  15. ;; getting assembly errors if I don't include it here; it
  16. ;; should be imported by the above 'INCLUDE' line
  17. ;;
  18. ;;         (Greg)
  19. ;;
  20.     IF &TYPE('StartSecureParams') = 'UNDEFINED' THEN
  21.  
  22. StartSecureParams    RECORD    0;    TYPE
  23. prompt            DS.L    1;        StringPtr
  24. guestSelected    DS.L    1;        pointer to a Boolean
  25. allowGuest        DS.B    1;        Boolean
  26. reserved1        DS.B    1;        Byte
  27. useDefault        DS.B    1;        Boolean
  28. reserved2        DS.B    1;        Byte
  29. userName        DS.L    1;        StringPtr
  30. startPb            DS.L    1;        PPCStartPBPtr
  31.                 ENDR
  32.  
  33.     ENDIF
  34.  
  35. noErr                        EQU            0
  36. noUserInteractionAllowed    EQU        -610
  37.  
  38.     SEG            'AutoGuest'
  39.  
  40. PPCAutoGuest        PROC        EXPORT
  41.  
  42.         EXPORT        OldPPCAddress
  43.         IMPORT        InForeGround
  44.         
  45.         
  46.         cmp.w        #$0E, d0        ; look for _StartSecureSession selector
  47.         bne.s        @dropThru        ; if not, fall through
  48.             
  49. ;;  Ok, this is the StartSecureSession trap.  We've got a ptr in a0 to the
  50. ;;  StartSecureParams block, which I've reconstructed above.  We want
  51. ;;  to try a PPCStart as <guest> first.
  52.  
  53.         move.l        a0, -(sp)        ; hang on to the SSP param block
  54.  
  55. ;;  Set ourselves up for the _PPCStart trap by moving just the PPCStartPBPtr
  56. ;;  into a0.
  57.         
  58. ;        add.w        #offsetof(StartSecureParams, pb), a0
  59.         add.w        #StartSecureParams.startPb, a0
  60.         move.l        (a0), a0
  61.         clr.l        $3E(a0)            ; set the <userRefNum> to <guest>
  62.         
  63.         _PPCStart
  64.         
  65. ;        move.w        #$02, d0        ; PPCStart selector
  66.         
  67. ;        dc.w        _PPC            ; _PPC Trap
  68.         
  69. ;;  Check for an error.  If none, we don't need authentication.
  70.  
  71.         cmp.w        #$00, d0
  72.         bne.s        @foregroundcheck
  73.         
  74. ;;  We've successfully avoided the authentication box.  Set the <guestSelected>
  75. ;;  field of the SSP param block.
  76.  
  77.         move.l        (sp), a0        ; Restore the SSP param block ptr
  78.         
  79. ;        add.w        #offsetof(StartSecureParams, guestSelected), a0
  80.         add.w        #StartSecureParams.guestSelected, a0
  81.         move.l        (a0), a0
  82.         move.b        #1, (a0)
  83.  
  84. ;;  Set the <userName> string to be a 0-char string.
  85.  
  86.         move.l        (sp), a0
  87. ;        add.w        #offsetof(StartSecureParams, userName), a0
  88.         add.w        #StartSecureParams.userName, a0
  89.         move.l        (a0), a0
  90.         move.b        #0, (a0)        ; set the length byte to 0
  91.  
  92. ;;  Return to caller.
  93.     
  94.         move.l        (sp)+, a0        ; once again, restore the SSP param block ptr
  95.         move.w        #noErr, d0        ; GA:  set result code to 'noErr'
  96.         rts
  97.  
  98. ;;    Greg Anderson addition:  first check to see if we are in the foreground
  99.  
  100. @foregroundcheck
  101.  
  102.         jsr            InForeGround    ; are we in the foreground?
  103.         bne.s        @authenticate    ; yup
  104.  
  105. ;; If we are in the background, return noUserInteractionAllowed <ga>
  106.         
  107.         move.l        (sp)+, a0        ; once again, restore the SSP param block ptr
  108.         move.w        #noUserInteractionAllowed, d0
  109.         rts
  110.         
  111. ;;  We need to clean up a little and then call StartSecureSession because
  112. ;;  PPCStart returned an error.
  113.  
  114.  
  115. @authenticate
  116.         
  117.         move.l        (sp)+, a0        ; restore the SSP param block ptr
  118.         move.w        #$E, d0            ; restore the SSS selector
  119.     
  120. @dropThru                            ; just go ahead and call the PPC dispatch
  121.         
  122. ;; Greg Anderson mod:  get rid of global, don't touch a3
  123.  
  124. BackToPPC
  125.  
  126.         move.l        OldPPCAddress, -(sp)
  127.         rts
  128.         
  129.                                     ; the actual address will be filled in
  130.                                     ; in PatchPPC
  131.  
  132. OldPPCAddress
  133.  
  134.         dc.l        1
  135.  
  136.         END
  137.